{
  "cells": [
    {
      "attachments": {},
      "cell_type": "markdown",
      "metadata": {
        "id": "uC0Mx0O-B7f5"
      },
      "source": [
        "<img src=\"https://github.com/chdb-io/chdb/raw/main/docs/_static/snake-chdb.png\" height=100><img src=\"https://assets.stickpng.com/images/5a6f11feab538104d4a30e80.png\" height=60>\n",
        "\n",
        "# chDB\n",
        "\n",
        "chDB / ClickHouse Taxi parquet demo on Google Colab\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "GoPM4RDYA5ae"
      },
      "outputs": [],
      "source": [
        "!pip install chdb --pre --upgrade\n",
        "\n",
        "!mkdir -p taxi\n",
        "!wget https://github.com/cwida/duckdb-data/releases/download/v1.0/taxi_2019_04.parquet -O taxi/201904.parquet\n",
        "!wget https://github.com/cwida/duckdb-data/releases/download/v1.0/taxi_2019_05.parquet -O taxi/201905.parquet\n",
        "!wget https://github.com/cwida/duckdb-data/releases/download/v1.0/taxi_2019_06.parquet -O taxi/201906.parquet"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "lx4LX4FoA-dw"
      },
      "outputs": [],
      "source": [
        "%%time\n",
        "import chdb\n",
        "chdb.query('SELECT * FROM file(\"taxi/*.parquet\", Parquet) LIMIT 5', 'Dataframe');"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "7uOHA7lcBwe0"
      },
      "outputs": [],
      "source": [
        "%%time\n",
        "# chDB\n",
        "chdb.query(\"SELECT count(*) FROM file('taxi/*.parquet', Parquet)  WHERE pickup_at > '2019-06-30'\", 'Dataframe');"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "KqUMxpIQCIaE"
      },
      "outputs": [],
      "source": [
        "# chDB\n",
        "\n",
        "import altair as alt\n",
        "import chdb\n",
        "\n",
        "data = chdb.query('SELECT toDate(pickup_at) as date, passenger_count FROM file(\"taxi/*.parquet\", Parquet) LIMIT 5', 'Dataframe');\n",
        "\n",
        "data\n",
        "#alt.Chart(data)"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
